package com.campus.config;

import com.campus.interceptor.JwtTokenAdminInterceptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * @author TaiZai
 * @data 2024/10/21 18:19
 */
@Configuration
public class WebMvcConfiguration implements WebMvcConfigurer {

    @Autowired
    private JwtTokenAdminInterceptor jwtTokenAdminInterceptor;

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        System.out.println("开始注册自定义拦截器......");

        // 后台管理员登陆拦截器
        registry.addInterceptor(jwtTokenAdminInterceptor)
                .addPathPatterns("/admin/**", "/ai/**")
                .excludePathPatterns("/user/login", "/admin/system/svg", "/admin/register",
                        "/user/send-phone-code");
    }
}
